package cn.icanci.loopstack.bic.sdk.burying.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Service;

/**
 * @author icanci
 * @since 1.0 Created in 2023/09/27 16:17
 */
@Aspect
@Service
public class SysLogAspect {
    @Around(value = "execution(* *(..)) && @annotation(sysLog))", argNames = "point,sysLog")
    public Object round(final ProceedingJoinPoint point, SysLog sysLog) throws Throwable {
        String clazz = ThreadLocalUtils.getClazz();
        String method = ThreadLocalUtils.getMethod();
        try {
            ThreadLocalUtils.fillThreadContext(point);
            return point.proceed();
        } finally {
            ThreadLocalUtils.removeThreadContext();
            ThreadLocalUtils.setClazz(clazz);
            ThreadLocalUtils.setMethod(method);
        }
    }

}
